//
//  BaseNavController.m
//  WisdomStar
//
//  Created by 谭飞 on 2018/10/22.
//  Copyright © 2018年 zhangliwen. All rights reserved.
//

#import "WSNavController.h"

@interface WSNavController ()

@end

@implementation WSNavController

// 只设置一次
+ (void)initialize
{
    if (self == [WSNavController class]) {
        // 获取当前整个应用程序下的所有导航条的外观
        // UINavigationBar *navBar = [UINavigationBar appearance];
        // 只影响当前类下面的导航条
        // 获取当前类下面的导航条
        UINavigationBar *navBar = [UINavigationBar appearanceWhenContainedInInstancesOfClasses:@[self]];
        [navBar setTitleTextAttributes:@{
                                         NSForegroundColorAttributeName : [UIColor whiteColor],
                                         NSFontAttributeName : WSFontMake(18)
                                         }];
        
        navBar.shadowImage = [UIImage new];
////        navBar.shadowImage = [UIImage imageWithColor:kThemeGreenColor];
//        [navBar setBackgroundImage:[UIImage imageWithColor:kThemeGreenColor] forBarMetrics:UIBarMetricsDefault];

//        UIBarButtonItem *barButtonItem = [UIBarButtonItem appearance];
//        [barButtonItem setTitleTextAttributes:@{NSForegroundColorAttributeName: RGB(0xE5FFFB),
//                                                NSFontAttributeName: WSFontMake(15)
//                                                } forState:UIControlStateNormal];
//        
//        [barButtonItem setTitleTextAttributes:@{NSForegroundColorAttributeName: RGB(0xE5FFFB),
//                                                NSFontAttributeName: WSFontMake(15)
//                                                } forState:UIControlStateHighlighted];
        
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
}


- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    if (viewController.navigationItem.leftBarButtonItem == nil && self.viewControllers.count > 0) {
        [viewController setHidesBottomBarWhenPushed:YES];
        
        // create back button
        UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithImage:WSImageMake(@"icon_back") style:UIBarButtonItemStyleDone target:self action:@selector(popViewControllerAnimated:)];
        
        viewController.navigationItem.leftBarButtonItem = backItem;
    }
    
    [super pushViewController:viewController animated:animated];
}


#pragma mark - StatusBar Style
- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}

@end
